<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="utf-8">
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>空明物联网服务平台</title>
  <link rel="stylesheet" href="/static/css/bootstrap.min.css" />
  <link rel="stylesheet" href="/static/css/base.css" />
</head>

<body>
  <div class="container-fluid">
    <h3>修改密码</h3>
    <br />
    <input class="form-control" type="password" id="password" name="password" placeholder="旧密码" required />
    <br />
    <input class="form-control" type="password" id="newspassword" name="newspassword" placeholder="新密码" required />
    <br />
    <input class="form-control" type="password" id="newspassword2" name="newspassword2" placeholder="新密码" required />
    <br />
    <button id="reg" type="submit" class="btn btn-primary">确定</button>
  </div>
  <script src="/static/js/jquery-2.1.4.min.js"></script>
  <script src="/static/js/base.js?version=1.0.0"></script>
  <script>
    $('#reg').click(function () {
      var password = $('#password').val();
      var newspassword = $('#newspassword').val();
      var newspassword2 = $('#newspassword2').val();

      if (password == '') {
        alert("请输入旧密码！");
        return false;
      }
      if (newspassword == '') {
        alert("请输入新密码！");
        return false;
      }
      if (newspassword2 == '') {
        alert("请输入新密码！");
        return false;
      }
      if (newspassword != newspassword2) {
        alert("两次密码输入不一致！");
        return false;
      }

      new AjaxRequest({
        type: "post",
        url: getServiceURL('changepassword'),
        param: {
          'password': password,
          'newspassword': newspassword
        },
        callBack: function (res) {
          if (res.res == 0) {
            alert(res.msg);
            return true;
          } else {
            alert(res.msg);
            return false;
          }
        }
      });
      return false;
    });
  </script>
  <!-- <script>
    $('#append_parent').hide();
  </script> -->
</body>

</html>